package com.budwk.app.sqfwV2.service.dulaying;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.sqfw.constants.SqfwFormSummaryConstants;
import com.budwk.app.sqfw.models.Sqfw_completeflow;
import com.budwk.app.sqfw.models.Sqfw_formSummary_new;
import com.budwk.app.sqfw.services.SqfwCompleteflowService;
import com.budwk.app.sqfw.services.SqfwFormsummaryNewService;
import com.budwk.app.sqfw.vo.GenerateExcelUrlVO;
import com.budwk.app.sqfw.vo.GenerateWordAndPdfUrlVO;
import com.budwk.app.sqfwDoc.bo.ExcelCreateConfig;
import com.budwk.app.sqfwDoc.codeGenerator.pdfGenerate.AbstractCustomerPdfCreateField;
import com.budwk.app.sqfwDoc.codeGeneratorV2.fileParam.CompleteFlowPdfParamForController;
import com.budwk.app.sqfwDoc.codeGeneratorV2.fileParam.PdfGenerateParam;
import com.budwk.app.sqfwDoc.codeGeneratorV2.generate.BasePdfGenerator;
import com.budwk.app.sqfwDoc.codeGeneratorV2.generate.ResultOfExcelGenerator;
import com.budwk.app.sqfwDoc.codeGeneratorV2.pdfService.CompleteFlowCommonPdfService;
import com.budwk.app.sqfwDoc.dto.CompleteFlowTemplateCodeUpdateDTO;
import com.budwk.app.sqfwDoc.dto.TemplateCodeUpdateDTO;
import com.budwk.app.sqfwV2.component.SummarySafetyCommponent;
import com.budwk.app.sqfwV2.dto.dto.dayingRoad.DownExcelLedgerReqVo;
import com.budwk.app.sqfwV2.dto.dulaying.DuLaYingPropagandaOrScreeningPdfDTO;
import com.budwk.app.sqfwV2.dto.dulaying.ScreeningHiddenDTO;
import com.budwk.app.sqfwV2.dto.vo.SummaryQueryReqVo;
import com.budwk.app.sqfwV2.enums.PropagandaOrScreeningEnum;
import com.budwk.app.sqfwV2.generator.dulaying.PropagandaPdfGenerator;
import com.budwk.app.sqfwV2.generator.dulaying.ScreeningPdfGenerator;
import com.budwk.app.sqfwV2.service.SummarySafetyService;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.sys.services.SysUserService;
import com.budwk.app.util.ClassUtil;
import com.budwk.app.util.StrUtil;
import com.budwk.app.util.poiUtils.CommonFormOfficeUtils;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.security.utils.SecurityUtil;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.xwpf.NiceXWPFDocument;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nutz.dao.Sqls;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import java.util.*;
import java.util.stream.Collectors;

import static com.budwk.app.util.poiUtils.CommonFormOfficeUtils.createConvergePdfAndUpload;
import static com.budwk.app.util.poiUtils.CommonFormOfficeUtils.generateWordDocument;

/**
 * @author 东方祥云低代码1.1
 * @since 2024-03-06
 * <p>
 * 都拉营街道宣传/排查记录 PropagandaOrScreening
 */
@IocBean
@Slf4j
public class PropagandaOrScreeningPdfService extends CompleteFlowCommonPdfService {

    @Inject
    SysUserService sysUserService;
    @Inject
    SqfwFormsummaryNewService sqfwFormsummaryNewService;
    @Inject
    SqfwCompleteflowService sqfwCompleteflowService;
    @Inject
    private SummarySafetyService summarySafetyService;
    @Inject
    private SummarySafetyCommponent summarySafetyCommponent;

    /**
     * 新增
     * @param dto
     */
    public void submitData(TemplateCodeUpdateDTO dto) {
        log.info("宣传/排查：{}", JSONUtil.toJsonStr(dto));
        CompleteFlowPdfParamForController paramForController = new CompleteFlowPdfParamForController();
        CompleteFlowTemplateCodeUpdateDTO completeFlowDataDTO = new CompleteFlowTemplateCodeUpdateDTO();

        // 设置时间
        Sqfw_formSummary_new formSummary = dto.getFormSummary();
        DuLaYingPropagandaOrScreeningPdfDTO pdfDTO = JSONUtil.toBean(formSummary.getParamData(), DuLaYingPropagandaOrScreeningPdfDTO.class);
        formSummary.setFillDate(pdfDTO.getDate());
        formSummary.setType(this.getSummaryType());

        completeFlowDataDTO.setFormSummary(formSummary);
        completeFlowDataDTO.setCompleteFlow(dto.getCompleteFlow());
        paramForController.setCompleteFlowDataDTO(completeFlowDataDTO);
        paramForController.setUserId(SecurityUtil.getUserId());

        // 创建任务
        summarySafetyCommponent.createOneTask(dto, null, getSummaryType());
        // 创建pdf
        super.createPdfAndMsg(paramForController);
    }

    /**
     * 更新 2.0版本
     * @param dto
     */
    public void update(TemplateCodeUpdateDTO dto) {
        log.info("宣传/排查更新：{}", JSONUtil.toJsonStr(dto));

        sqfwFormsummaryNewService.updateIgnoreNull(dto.getFormSummary());
        Sqfw_formSummary_new formSummaryNew = sqfwFormsummaryNewService.fetch(dto.getFormSummary().getId());
        CompleteFlowPdfParamForController paramForController = new CompleteFlowPdfParamForController();
        CompleteFlowTemplateCodeUpdateDTO updateDTO = new CompleteFlowTemplateCodeUpdateDTO();

        // 设置时间
        Sqfw_formSummary_new formSummary = dto.getFormSummary();
        DuLaYingPropagandaOrScreeningPdfDTO pdfDTO = JSONUtil.toBean(formSummary.getParamData(), DuLaYingPropagandaOrScreeningPdfDTO.class);
        formSummary.setFillDate(pdfDTO.getDate());

        updateDTO.setFormSummary(formSummaryNew);
        paramForController.setCompleteFlowDataDTO(updateDTO);
        paramForController.setCompleteFlowId(formSummaryNew.getSqfwFlowId());
        paramForController.setUserId(SecurityUtil.getUserId());
        super.reCreatePdfAndMsg(paramForController);
    }

    /**
     * pdf合集下载 2.0版本 app端
     *
     * @param reqVo
     * @return
     */
    public List<ResultOfExcelGenerator> downPdfList(DownExcelLedgerReqVo reqVo) {
        List<ExcelCreateConfig> excelConfigList = new ArrayList<>();
        if (reqVo.isDownTemplate()) {
            ExcelCreateConfig config = new ExcelCreateConfig();
            config.setFileIdentity(reqVo.getFileCode());
            config.setOnlyGenerateTemplateFlag(true);
            excelConfigList.add(config);
        } else {
            Map<String,Object> param = new HashMap<>();
            param.put("start", reqVo.getFillStartDate());
            param.put("end", reqVo.getFillEndDate());
            param.put("type", reqVo.getFileType());
            if (reqVo.isCheckData()) {
                for (PropagandaOrScreeningEnum pdf : PropagandaOrScreeningEnum.getPdf()) {
                    ExcelCreateConfig config = new ExcelCreateConfig();
                    config.setFileIdentity(pdf.getCode());
                    config.setCreateExcelFileFlag(false);
                    config.setParam(param);
                    excelConfigList.add(config);
                }
            } else {
                ExcelCreateConfig config = new ExcelCreateConfig();
                config.setFileIdentity(reqVo.getFileCode());
                config.setCreateExcelFileFlag(true);
                config.setParam(param);
                excelConfigList.add(config);
            }
        }
        List<GenerateExcelUrlVO> urlVOList = downPdfList(excelConfigList);

        List<ResultOfExcelGenerator> resultList = new ArrayList<>();
        for (GenerateExcelUrlVO vo : urlVOList) {
            ResultOfExcelGenerator result = new ResultOfExcelGenerator();
            result.setPassCreateConditionFlag(vo.getCreateConditionFlag());
            result.setExcelUrl(vo.getExcelUrl());
            result.setFileIdentity(vo.getFileIdentity());
            resultList.add(result);
        }

        return resultList;
    }

    /**
     * 获取列表数据 2.0版本
     * @return
     */
    public Result<?> list(Integer pageNo, Integer pageSize, String fillDate, String sort, String type) {
        SummaryQueryReqVo dto = new SummaryQueryReqVo();
        dto.setPageNo(pageNo);
        dto.setPageSize(pageSize);
        dto.setSort(sort);
        dto.setFillDate(fillDate);
        dto.setFillType(getSummaryType());

        if (StringUtils.isNotBlank(type)) {
            SqlExpressionGroup sqlExpressionGroup = new SqlExpressionGroup();
            sqlExpressionGroup.and("param_data->>'type'", "=", type);

            dto.setSqlExpressionGroup(sqlExpressionGroup);
        }

        return summarySafetyService.listSummaryByPage(dto);
    }

    public void createPdfAndMsg(TemplateCodeUpdateDTO templateCodeUpdateDTO) {
        CompleteFlowPdfParamForController paramForController = new CompleteFlowPdfParamForController();
        CompleteFlowTemplateCodeUpdateDTO dto = new CompleteFlowTemplateCodeUpdateDTO();
        dto.setCompleteFlow(templateCodeUpdateDTO.getCompleteFlow());
        dto.setFormSummary(templateCodeUpdateDTO.getFormSummary());
        paramForController.setCompleteFlowDataDTO(dto);
        paramForController.setUserId(SecurityUtil.getUserId());
        super.createPdfAndMsg(paramForController);
    }

    /**
     * pdf合集下载（通过表：sqfw_form_summary_new 的 id 下载pdf合集）
     * @param excelConfigList
     * @param summaryIds
     * @return
     */
    public List<GenerateExcelUrlVO> downPdfListToSummaryIds(List<ExcelCreateConfig> excelConfigList, List<String> summaryIds) {

        List<GenerateExcelUrlVO> generateExcelUrlVOS = new ArrayList<>();

        for (ExcelCreateConfig config : excelConfigList) {

            // 模板下载
            if (config.getOnlyGenerateTemplateFlag()) {
                GenerateExcelUrlVO urlVO = new GenerateExcelUrlVO();
                String url = downWordTemplate(config);
                urlVO.setExcelUrl(url);
                generateExcelUrlVOS.add(urlVO);
                return generateExcelUrlVOS;
            }

            // 数据下载
            String fileName;
            String type;
            if (PropagandaOrScreeningEnum.PROPAGANDA.getCode().equals(config.getFileIdentity())) {
                fileName = PropagandaOrScreeningEnum.PROPAGANDA.getCompilationName();
                type = PropagandaOrScreeningEnum.PROPAGANDA.getName();
            } else {
                fileName = PropagandaOrScreeningEnum.SCREENING.getCompilationName();
                type = PropagandaOrScreeningEnum.SCREENING.getName();
            }
            String sql = "select sc.resource_path from shequ.sqfw_completeflow sc left join shequ.sqfw_form_summary_new sfsn " +
                    "on sc.id = sfsn.sqfw_flow_id where " +
                    "sfsn.param_data->>'type' = '"+ type +"' and sfsn.id in " + StrUtil.formatIds(summaryIds) +
                    "and sc.resource_path != 'error' and sc.resource_path != 'creating' ";
            sql += "order by sc.create_date asc";
            List<Sqfw_completeflow> completeFlowList = sqfwCompleteflowService.listEntity(Sqls.create(sql));

            GenerateExcelUrlVO generateExcelUrlVO = new GenerateExcelUrlVO();
            generateExcelUrlVO.setFileIdentity(config.getFileIdentity());

            if (completeFlowList != null && completeFlowList.size() > 0) {
                generateExcelUrlVO.setCreateConditionFlag(true);
            } else {
                generateExcelUrlVO.setCreateConditionFlag(false);
            }

            // 数据检测
            if (!config.getCreateExcelFileFlag() || completeFlowList == null || completeFlowList.size() == 0) {
                generateExcelUrlVOS.add(generateExcelUrlVO);
                continue;
            }

            List<String> pdfList = completeFlowList.stream().map(Sqfw_completeflow::getResourcePath).collect(Collectors.toList());

            try {
                String url = createConvergePdfAndUpload(pdfList, fileName);
                generateExcelUrlVO.setExcelUrl(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            generateExcelUrlVOS.add(generateExcelUrlVO);
        }

        return generateExcelUrlVOS;
    }

    /**
     * app 2.0
     * @param excelConfigList
     * @return
     */
    public List<GenerateExcelUrlVO> downPdfList(List<ExcelCreateConfig> excelConfigList) {

        List<GenerateExcelUrlVO> generateExcelUrlVOS = new ArrayList<>();

        Object t = excelConfigList.get(0).getParam().get("type");

        String sql = "select sc.resource_path, sfsn.param_data->>'type' as file_type from shequ.sqfw_completeflow sc left join shequ.sqfw_form_summary_new sfsn " +
                "on sc.id = sfsn.sqfw_flow_id where " +
                "sfsn.create_by='" + SecurityUtil.getUserId() +"' " +
                "and sc.resource_path != 'error' and sc.resource_path != 'creating' ";
        if (t != null && StringUtils.isNotBlank(t.toString())) {
            sql += "and sfsn.param_data->>'type' = '"+ t + "' ";
        }
        sql += "order by sfsn.fill_date asc";

        List<Sqfw_completeflow> flowList = sqfwCompleteflowService.listEntity(Sqls.create(sql));

        for (ExcelCreateConfig config : excelConfigList) {
            // 模板下载
            if (config.getOnlyGenerateTemplateFlag()) {
                GenerateExcelUrlVO urlVO = new GenerateExcelUrlVO();
                String url = downWordTemplate(config);
                urlVO.setExcelUrl(url);
                generateExcelUrlVOS.add(urlVO);
                return generateExcelUrlVOS;
            }

            // 数据下载
            String fileName;
            String type;
            if (PropagandaOrScreeningEnum.PROPAGANDA.getCode().equals(config.getFileIdentity())) {
                fileName = PropagandaOrScreeningEnum.PROPAGANDA.getCompilationName();
                type = PropagandaOrScreeningEnum.PROPAGANDA.getName();
            } else {
                fileName = PropagandaOrScreeningEnum.SCREENING.getCompilationName();
                type = PropagandaOrScreeningEnum.SCREENING.getName();
            }

            List<Sqfw_completeflow> completeFlowList = new ArrayList<>();
            for (Sqfw_completeflow flow : flowList) {
                if (type.equals(flow.getFileType())) {
                    completeFlowList.add(flow);
                }
            }

            GenerateExcelUrlVO generateExcelUrlVO = new GenerateExcelUrlVO();
            generateExcelUrlVO.setFileIdentity(config.getFileIdentity());

            if (completeFlowList != null && completeFlowList.size() > 0) {
                generateExcelUrlVO.setCreateConditionFlag(true);
            } else {
                generateExcelUrlVO.setCreateConditionFlag(false);
            }

            // 数据检测
            if (!config.getCreateExcelFileFlag() || completeFlowList == null || completeFlowList.size() == 0) {
                generateExcelUrlVOS.add(generateExcelUrlVO);
                continue;
            }

            List<String> pdfList = completeFlowList.stream().map(Sqfw_completeflow::getResourcePath).collect(Collectors.toList());

            try {
                String url = createConvergePdfAndUpload(pdfList, fileName);
                generateExcelUrlVO.setExcelUrl(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            generateExcelUrlVOS.add(generateExcelUrlVO);
        }

        return generateExcelUrlVOS;
    }

    /**
     * pdf合集下载（通过sqfwIdList下载pdf合集）
     * @param excelConfigList
     * @param sqfwIdList
     * @return
     */
    public List<GenerateExcelUrlVO> downPdfList(List<ExcelCreateConfig> excelConfigList, List<String> sqfwIdList) {

        List<GenerateExcelUrlVO> generateExcelUrlVOS = new ArrayList<>();

        for (ExcelCreateConfig config : excelConfigList) {

            // 模板下载
            if (config.getOnlyGenerateTemplateFlag()) {
                GenerateExcelUrlVO urlVO = new GenerateExcelUrlVO();
                String url = downWordTemplate(config);
                urlVO.setExcelUrl(url);
                generateExcelUrlVOS.add(urlVO);
                return generateExcelUrlVOS;
            }

            // 数据下载
            String fileName;
            String type;
            if (PropagandaOrScreeningEnum.PROPAGANDA.getCode().equals(config.getFileIdentity())) {
                fileName = PropagandaOrScreeningEnum.PROPAGANDA.getCompilationName();
                type = PropagandaOrScreeningEnum.PROPAGANDA.getName();
            } else {
                fileName = PropagandaOrScreeningEnum.SCREENING.getCompilationName();
                type = PropagandaOrScreeningEnum.SCREENING.getName();
            }
            String sql = "select sc.resource_path from shequ.sqfw_completeflow sc left join shequ.sqfw_form_summary_new sfsn " +
                    "on sc.id = sfsn.sqfw_flow_id where " +
                    "sfsn.param_data->>'type' = '"+ type +"' and sc.sqfw_id in "+ StrUtil.formatIds(sqfwIdList) +
                    "and sc.resource_path != 'error' and sc.resource_path != 'creating' ";
            sql += "order by sc.create_date asc";
            List<Sqfw_completeflow> completeFlowList = sqfwCompleteflowService.listEntity(Sqls.create(sql));

            GenerateExcelUrlVO generateExcelUrlVO = new GenerateExcelUrlVO();
            generateExcelUrlVO.setFileIdentity(config.getFileIdentity());

            if (completeFlowList != null && completeFlowList.size() > 0) {
                generateExcelUrlVO.setCreateConditionFlag(true);
            } else {
                generateExcelUrlVO.setCreateConditionFlag(false);
            }

            // 数据检测
            if (!config.getCreateExcelFileFlag() || completeFlowList == null || completeFlowList.size() == 0) {
                generateExcelUrlVOS.add(generateExcelUrlVO);
                continue;
            }

            List<String> pdfList = completeFlowList.stream().map(Sqfw_completeflow::getResourcePath).collect(Collectors.toList());

            try {
                String url = createConvergePdfAndUpload(pdfList, fileName);
                generateExcelUrlVO.setExcelUrl(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            generateExcelUrlVOS.add(generateExcelUrlVO);
        }

        return generateExcelUrlVOS;
    }

    /**
     * 获取单位下所有pdf数据
     * @param excelConfigList
     * @return
     */
    public List<GenerateExcelUrlVO> downPdfListToUnit(List<ExcelCreateConfig> excelConfigList) {
        Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());

        List<GenerateExcelUrlVO> generateExcelUrlVOS = new ArrayList<>();

        for (ExcelCreateConfig config : excelConfigList) {

            // 模板下载
            if (config.getOnlyGenerateTemplateFlag()) {
                GenerateExcelUrlVO urlVO = new GenerateExcelUrlVO();
                String url = downWordTemplate(config);
                urlVO.setExcelUrl(url);
                generateExcelUrlVOS.add(urlVO);
                return generateExcelUrlVOS;
            }

            // 数据下载
            String fileName;
            String type;
            if (PropagandaOrScreeningEnum.PROPAGANDA.getCode().equals(config.getFileIdentity())) {
                fileName = PropagandaOrScreeningEnum.PROPAGANDA.getCompilationName();
                type = PropagandaOrScreeningEnum.PROPAGANDA.getName();
            } else {
                fileName = PropagandaOrScreeningEnum.SCREENING.getCompilationName();
                type = PropagandaOrScreeningEnum.SCREENING.getName();
            }
            String sql = "select sc.resource_path from shequ.sqfw_completeflow sc left join shequ.sqfw_form_summary_new sfsn " +
                    "on sc.id = sfsn.sqfw_flow_id where " +
                    "sfsn.param_data->>'type' = '"+ type +"' and sfsn.unit_id = '" + user.getUnitId() + "'" +
                    " and sc.resource_path != 'error' and sc.resource_path != 'creating' ";
            sql += "order by sc.create_date asc";
            List<Sqfw_completeflow> completeFlowList = sqfwCompleteflowService.listEntity(Sqls.create(sql));

            GenerateExcelUrlVO generateExcelUrlVO = new GenerateExcelUrlVO();
            generateExcelUrlVO.setFileIdentity(config.getFileIdentity());

            if (completeFlowList != null && completeFlowList.size() > 0) {
                generateExcelUrlVO.setCreateConditionFlag(true);
            } else {
                generateExcelUrlVO.setCreateConditionFlag(false);
            }

            // 数据检测
            if (!config.getCreateExcelFileFlag() || completeFlowList == null || completeFlowList.size() == 0) {
                generateExcelUrlVOS.add(generateExcelUrlVO);
                continue;
            }

            List<String> pdfList = completeFlowList.stream().map(Sqfw_completeflow::getResourcePath).collect(Collectors.toList());

            try {
                String url = createConvergePdfAndUpload(pdfList, fileName);
                generateExcelUrlVO.setExcelUrl(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            generateExcelUrlVOS.add(generateExcelUrlVO);
        }

        return generateExcelUrlVOS;
    }

    /**
     * 获取用户自定义字段 代码生成器已经自动填充
     * 无需特殊修改
     *
     * @param paramData json字符串
     * @return 结果
     */
    @Override
    protected AbstractCustomerPdfCreateField getCustomerPdfField(String paramData) {
        return JSONObject.parseObject(paramData, DuLaYingPropagandaOrScreeningPdfDTO.class);
    }

    /**
     * 允许用户自定义填充在创建pdf时所提供的数据
     *
     * @param pdfGenerateParam 创建pdf所提供的数据
     */
    @Override
    protected void customerPopularPdfGenerateParam(PdfGenerateParam pdfGenerateParam) {

    }

    /**
     * 在这里设置生成pdf的所有generator
     *
     * @param pdfGenerateParam 创建pdf的参数
     * @return 生成pdf的generator合集
     */
    @Override
    protected List<BasePdfGenerator> getPdfGenerator(PdfGenerateParam pdfGenerateParam) {
        List<BasePdfGenerator> generatorList = Lists.newArrayList();
        DuLaYingPropagandaOrScreeningPdfDTO dto = (DuLaYingPropagandaOrScreeningPdfDTO)
                pdfGenerateParam.getAbstractCustomerPdfCreateField();

        // 在这里添加自己的generator
        if (PropagandaOrScreeningEnum.PROPAGANDA.getName().equals(dto.getType())) {
            List<String> themeList = Arrays.asList(dto.getTheme().split(","));
            for (String theme : themeList) {
                PropagandaPdfGenerator propagandaPdfGenerator = new PropagandaPdfGenerator();
                propagandaPdfGenerator.setTheme(theme);
                generatorList.add(propagandaPdfGenerator);
            }
        }
        if (PropagandaOrScreeningEnum.SCREENING.getName().equals(dto.getType())) {
            List<String> themeList = Arrays.asList(dto.getTheme().split(","));
            for (String theme : themeList) {
                ScreeningPdfGenerator screeningPdfGenerator = new ScreeningPdfGenerator();
                screeningPdfGenerator.setTheme(theme);
                generatorList.add(screeningPdfGenerator);
            }
        }
        return generatorList;
    }

    /**
     * 用户自定义下载pdf文件的名称
     *
     * @param pdfGenerateParam 创建pdf所提供的参数
     * @return 结果
     */
    @Override
    protected String getDownloadFileName(PdfGenerateParam pdfGenerateParam) {
        DuLaYingPropagandaOrScreeningPdfDTO dto = (DuLaYingPropagandaOrScreeningPdfDTO)
                pdfGenerateParam.getAbstractCustomerPdfCreateField();
        if (PropagandaOrScreeningEnum.PROPAGANDA.getName().equals(dto.getType())) {
            return PropagandaOrScreeningEnum.PROPAGANDA.getOneName();
        }
        if (PropagandaOrScreeningEnum.SCREENING.getName().equals(dto.getType())) {
            return PropagandaOrScreeningEnum.SCREENING.getOneName();
        }
        return null;
    }

    /**
     * 第五张表中的需要的类型，详情见 {@link SqfwFormSummaryConstants}
     *
     * @return 返回数据
     */
    @Override
    public String getSummaryType() {
        return SqfwFormSummaryConstants.propaganda_screening;
    }

    /**
     * 下载word模板
     * @param config
     * @return
     */
    private String downWordTemplate(ExcelCreateConfig config) {
        String fileName = "";

        Map<String, Object> dataMap = JSONUtil.parseObj(new Sqfw_formSummary_new(), false);
        dataMap.putAll(JSONUtil.parseObj(new DuLaYingPropagandaOrScreeningPdfDTO(), false));
        dataMap.putAll(JSONUtil.parseObj(new ScreeningHiddenDTO(), false));
        List<NiceXWPFDocument> xwpfDocumentList = new ArrayList<>();

        if (PropagandaOrScreeningEnum.PROPAGANDA.getCode().equals(config.getFileIdentity())) {
            fileName = PropagandaOrScreeningEnum.PROPAGANDA.getName();

            xwpfDocumentList.add(getNiceXWPFDocument(dataMap, new PropagandaPdfGenerator().getTemplatePath(null)));
        }
        if (PropagandaOrScreeningEnum.SCREENING.getCode().equals(config.getFileIdentity())) {
            fileName = PropagandaOrScreeningEnum.SCREENING.getOneName();

            xwpfDocumentList.add(getNiceXWPFDocument(dataMap, new ScreeningPdfGenerator().getTemplatePath(null)));
        }

        GenerateWordAndPdfUrlVO vo = CommonFormOfficeUtils.wordUpload(xwpfDocumentList, fileName + "模板");
        return vo.getWordUrl();
    }

    /**
     * 生成单个word
     * @param dataMap
     * @param templateName
     * @return
     */
    private NiceXWPFDocument getNiceXWPFDocument(Map<String, Object> dataMap, String templateName) {
        for (String key : dataMap.keySet()) {
            dataMap.put(key, "");
        }
        String fieldName = ClassUtil.getField(DuLaYingPropagandaOrScreeningPdfDTO::getImages);
        dataMap.put(fieldName + "s", new ArrayList<>());

        XWPFTemplate xwpfTemplate = generateWordDocument(dataMap, null, templateName);
        return xwpfTemplate.getXWPFDocument();
    }
}
